package dabs.engine.plant;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import dabs.engine.DummyInterface;
import dabs.engine.control.ComponentCommand;
import dabs.ginterface.CommandParser;

public class PumpTest {

	Pump pump;
	DummyInterface dinterface;
	CommandParser parser;
	ComponentCommand command;
	
	@Before
	public void setUp() throws Exception {
		dinterface = new DummyInterface();
		pump = new Pump(dinterface, "pump1", 10, 10);
		parser = new CommandParser();		
	}
	
	
	@Test
	public void testCommandParsingIssues(){
		
		command = (ComponentCommand)(parser.asComponentCommand("pump 20"));
		pump.runCommand(command);		
		assertEquals(pump.getFlowAmount(),20);
		dinterface.makeEmpty();		
		command = (parser.asComponentCommand("pump1 sth"));
		pump.runCommand(command);
		assertTrue(dinterface.get().getDescription().contains("Rods must be set to"));		
		ArrayList<String> args = new ArrayList<String>();
		args.add("-10");
		pump.runCommand(new ComponentCommand("pump",  args));		
		assertTrue(pump.getFlowAmount() != -10);	//rod level can't be negative, an it is not set to that.
		assertTrue(pump.getFlowAmount() == 20);    //.. and stays as it was
	}
	
	
	
	
	

}
